// packageF/others/customerCenter/component/userDetail/myCart/myCart.js
const app = getApp();
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    keywork: {
      type: null
    },
    memberId: {
      type: null
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    strUrl: 'plugin.wechat-chat-sidebar.frontend.controller.customer.cart.index',
    cartList: [],
    loading: false,
    finished: true,
  },
  lifetimes: {
    attached() {
      let language = wx.getStorageSync("langIndex");
      this.setData({
        language: language.en,
      });
      this.getData();
    },
  },
  /**
   * 组件的方法列表
   */
  methods: {
    getData(){
      let json = {};
      if(this.data.keywork == 'customer'){
        this.data.strUrl = 'plugin.customer-center.frontend.controllers.customer.cart.index';
        json.member_id = this.data.memberId;
      }
      let urlStr = app.getNetAddresss(this.data.strUrl);
      app._postNetWork({
        url: urlStr,
        data: json,
        success: (resdata) => {
          let res = resdata.data
          if (res.result == 1) {
            this.setData({
              cartList:res.data.list
            })
          } else {
            wx.showToast({
              icon: 'none',
              title: res.msg,
              duration: 1500
            });
          }
        },
        fail: function (res) {
          console.log(res);
        }
      });
    }
  }
})
